home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Snippets / SimpleParseUtils 1.0.3 / SimpleParseUtils.h < prev   
C/C++ Source or Header  |  1996-01-14  |  3KB  |  67 lines

  1. #pragma once
  2. /*
  3.     File:        SimpleParseUtils.h
  4.     
  5.     Contains:    Utilities for useful for very simple
  6.                 parsing tasks.
  7.     
  8.     Version:    1.0.3 (for System 7.x)
  9.     
  10.     Copyright:    ©1995 Chris K. Thomas.  All Rights Reserved.
  11. */
  12.  
  13. static const unsigned char    *whiteSpaces = "\p \t\r\n";
  14. static const unsigned char    *tokenBreaks = "\p{}[]();";    // these are both wordbreaks and tokens
  15. static const unsigned char    *quoteBreaks = "\p\"\'‘’“”";
  16. static const unsigned char    *wordBreaks = "\p \t\r\n~$%+-*/:;,(){}#[]~`\\'\"!\0";
  17. static const unsigned char    *wordBreaksNoWhiteSpace = "\p$%+-*/:;,{}#[]~`\\'\"!\0";
  18. static const unsigned char    *alphaBreaks = "\pabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$%+-*/:;,{}#[]~`\\'\"!\0";
  19. static const unsigned char    *endLines = "\p\r\n";
  20. static const unsigned char    *lineBreaks = "\p\r\n";
  21.  
  22. // * if inMem points to a the same string as inString, true
  23. Boolean StrEquals(const unsigned char *inString, char *inMem);
  24.  
  25. // * if inMem points to a the same string as inString followed by whitespace, true
  26. Boolean StrEqualsToken(const unsigned char *inString, char *inMem);
  27.  
  28. // * if inMem points to a the same string as inString followed by whitespace, true
  29. Boolean PtrEqualsToken(const Ptr inString, char *inMem);
  30.  
  31. // * if inMem points to a char which is in inString, true
  32. Boolean StrEqualsChars(const unsigned char *inString, char *inMem);
  33.  
  34. // * count whitespace chars
  35. long CountWhiteSpace(char *inMem, long inLength);
  36.  
  37. // * return a pascal string containing the next token
  38. StringPtr GetTokenString(char *inMem, long inLength);
  39.  
  40. // * return a length-unlimited string containing the next token
  41. Ptr GetTokenPtr(char *inMem, long inLength);
  42.  
  43. // * return a token with a custom delimiting string
  44. Ptr GetDelimitedToken(const unsigned char *inDelimiter, char *inMem, long inLength);
  45.  
  46. // * return the char in inString actually found
  47. short FindSelectChar(const unsigned char *inString, char *inMem, long inLength);
  48.  
  49. // * look for inFindChar until either we hit a char in inUntil or index >= inLength
  50. Boolean FindCharUntil(short inFindChar, const unsigned char *inUntil, char *inMem, long inLength);
  51.  
  52. // * get all text from inMem to end of line
  53. Ptr    GetEntireLine(char *inMem, long inLength);
  54.  
  55. // * for checking dot extensions (.c .h .pas .r, etc)
  56. Boolean StringHasExtension(const unsigned char * inExtension, const unsigned char *inString);
  57.  
  58. // * append a pstring to the given Ptr
  59. void PtrAppendStr(Ptr inDestPtr, unsigned char *inStringToAppend);
  60.  
  61. // * strip all but one space from contiguous runs of whitespace; can shrink inDestPtr
  62. void CollapsePtrWhiteSpace(Ptr inDestPtr);
  63.  
  64. // * add a .dot extension to a Mac filename (yuk!)
  65. void AddDotExtension(const Str255 inString, const Str255 inDot, Str255 outString);
  66.  
  67.